package lxh.com.union.logic_business.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhy.autolayout.AutoRelativeLayout;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import de.hdodenhof.circleimageview.CircleImageView;
import lxh.com.union.R;
import lxh.com.union.frame.mvp.FrameMvpFragment;
import lxh.com.union.logic_business.model.bean.OrderCountBean;
import lxh.com.union.logic_business.present.MinePresent;
import lxh.com.union.logic_business.ui.activity.LoginActivity;

import lxh.com.union.logic_business.ui.mvpview.IMineView;
import q.rorbin.badgeview.QBadgeView;

/**
 * Created by Administrator on 2017/11/28.
 */

public class MineFragment extends FrameMvpFragment<MinePresent> implements IMineView {
    @BindView(R.id.tv_about)
    TextView mTvAbout;
    @BindView(R.id.iv_mine_msg)
    ImageView mIvMineMsg;
    @BindView(R.id.civ_header)
    CircleImageView mCivHeader;
    @BindView(R.id.tv_login)
    TextView mTvLogin;
    @BindView(R.id.rl_all_order)
    AutoRelativeLayout mRlAllOrder;
    @BindView(R.id.tv_wait_pay)
    TextView mTvWaitPay;
    @BindView(R.id.tv_wait_send)
    TextView mTvWaitSend;
    @BindView(R.id.tv_wait_receive)
    TextView mTvWaitReceive;
    @BindView(R.id.tv_wait_comment)
    TextView mTvWaitComment;
    @BindView(R.id.tv_sale_after)
    TextView mTvSaleAfter;
    @BindView(R.id.tv_my_collect)
    TextView mTvMyCollect;
    @BindView(R.id.tv_my_coupon)
    TextView mTvMyCoupon;
    @BindView(R.id.tv_my_recive_address)
    TextView mTvMyReciveAddress;
    @BindView(R.id.tv_modify_pwd)
    TextView mTvModifyPwd;
    @BindView(R.id.tv_feedback)
    TextView mTvFeedback;
    @BindView(R.id.tv_online_service)
    TextView mTvOnlineService;
    @BindView(R.id.tv_contact_us)
    TextView mTvContactUs;
    Unbinder unbinder;

    @Override
    protected MinePresent createPresent() {
        return new MinePresent();
    }

    @Override
    protected int getContentView() {
        return R.layout.fragment_mine;
    }

    @Override
    protected void initView(View view) {

    }

    @Override
    protected void initData() {
        mPresent.loadOrderCount();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.tv_about, R.id.iv_mine_msg, R.id.civ_header, R.id.rl_all_order, R.id.tv_wait_pay, R.id.tv_wait_send, R.id.tv_wait_receive, R.id.tv_wait_comment, R.id.tv_sale_after, R.id.tv_my_collect, R.id.tv_my_coupon, R.id.tv_my_recive_address, R.id.tv_modify_pwd, R.id.tv_feedback, R.id.tv_online_service, R.id.tv_contact_us})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_about:
                break;
            case R.id.iv_mine_msg:
                break;
            case R.id.civ_header:
                startActivity(LoginActivity.class);
                break;
            case R.id.rl_all_order:
                break;
            case R.id.tv_wait_pay:
                break;
            case R.id.tv_wait_send:
                break;
            case R.id.tv_wait_receive:
                break;
            case R.id.tv_wait_comment:
                break;
            case R.id.tv_sale_after:
                break;
            case R.id.tv_my_collect:
                break;
            case R.id.tv_my_coupon:
                break;
            case R.id.tv_my_recive_address:
                break;
            case R.id.tv_modify_pwd:
                break;
            case R.id.tv_feedback:
                break;
            case R.id.tv_online_service:
                break;
            case R.id.tv_contact_us:
                break;
        }
    }

    @Override
    public void getOrderCount(OrderCountBean bean) {
        if (bean!=null){
            for (OrderCountBean.DataBean dataBean : bean.getData()) {
                if (dataBean==null||dataBean.getTOTAL()<=0){
                    continue;
                }
                switch (Integer.valueOf(dataBean.getORDER_TYPE())){
                    case 1:
                        new QBadgeView(getContext()).bindTarget(mTvWaitPay).setBadgeNumber(dataBean.getTOTAL());
                        break;
                    case 2:
                        new QBadgeView(getContext()).bindTarget(mTvWaitSend).setBadgeNumber(dataBean.getTOTAL());
                        break;
                    case 3:
                        new QBadgeView(getContext()).bindTarget(mTvWaitReceive).setBadgeNumber(dataBean.getTOTAL());
                        break;
                    case 4:
                        new QBadgeView(getContext()).bindTarget(mTvWaitComment).setBadgeNumber(dataBean.getTOTAL());
                        break;
                    case 5:
                        new QBadgeView(getContext()).bindTarget(mTvSaleAfter).setBadgeNumber(dataBean.getTOTAL());
                        break;
                }
            }
        }
    }


}
